using System;
using CommandSystem;
using RgCore.Modules;

namespace RgCore.Commands.ModuleCommands
{
    public class List : ICommand
    {
        public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
        {
            if (!sender.CheckPermission(PlayerPermissions.ServerConsoleCommands))
            {
                response = "你没有权限执行此命令";
                return false;
            }

            response = "已加载的集成插件：";
            foreach (var a in ModuleManager.Plugins)
            {
                response += $"\n{a.Instance.Name} ({a.Instance.Id}) [{a.Instance.Priority}]";
            }

            return true;
        }

        public string Command { get; } = "list";
        public string[] Aliases { get; } = Array.Empty<string>();
        public string Description { get; } = "获取已加载的集成插件";
    }
}